<?php

/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitepage
 * @copyright  Copyright 2010-2011 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: Create.php 2011-05-05 9:40:21Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
class Sitepage_Form_Topic_Create extends Engine_Form {
	
	public function init() {
		
		$page_id = Zend_Controller_Front::getInstance ()->getRequest ()->getParam ( 'page_id', null );
		$tab_id = Zend_Controller_Front::getInstance ()->getRequest ()->getParam ( 'tab', null );
		
		$view = Zend_Registry::isRegistered ( 'Zend_View' ) ? Zend_Registry::get ( 'Zend_View' ) : null;
		$url = $view->url ( array ('page_url' => Engine_Api::_ ()->sitepage ()->getPageUrl ( $page_id ), 'tab' => $tab_id ), 'sitepage_entry_view', true );
		
		$this->setTitle ( 'Post Discussion Topic' )->setAttrib ( 'id', 'sitepage_topic_create' );
		
		$this->addElement ( 'Text', 'title', array ('label' => 'Title', 'allowEmpty' => false, 'required' => true, 'filters' => array (new Engine_Filter_Censor (), new Engine_Filter_HtmlSpecialChars () ), 'validators' => array (array ('StringLength', true, array (1, 64 ) ) ) ) );
		
		$this->addElement ( 'Textarea', 'body', array ('label' => 'Message', 'allowEmpty' => false, 'required' => true, 'filters' => array (new Engine_Filter_Censor (), new Engine_Filter_HtmlSpecialChars (), new Engine_Filter_EnableLinks () ) ) );
		
		$this->addElement ( 'Checkbox', 'watch', array ('label' => 'Send me notifications when other members reply to this topic.', 'value' => true ) );
		
		$this->addElement ( 'Button', 'submit', array ('label' => 'Post Topic', 'ignore' => true, 'type' => 'submit', 'decorators' => array ('ViewHelper' ) ) );
		
		$this->addElement ( 'Cancel', 'cancel', array ('label' => 'cancel', 'prependText' => ' or ', 'type' => 'link', 'link' => true, 'href' => $url, 'decorators' => array ('ViewHelper' ) ) );
		
		$this->addDisplayGroup ( array ('submit', 'cancel' ), 'buttons' );
	}

}

?>